/**
 * File WEBO Site InSight (http://www.webogroup.com/)
 * Defines a number of general functions (i.e. converting language files and
 * logging).
 **/
/* lod operations */
function log (txt, wnd){
	var wnds = ["logmain", "logtxt"];
	document.getElementById(wnds[wnd - 1]).value += txt + "\r\n";
}
/* provide joomla-ralted localization strings */
function lang_joomla15 (str) {
	str = str.replace(/^define\('/,"").replace(/'\);$/,"").replace(/',\s'/,"###").replace(/"/g,"'").split('###');
	return (str.length > 1) ? str[0].replace(/_/,"").replace(/_/g," ").toUpperCase() + "=" + str[1] : '';
}
/* split XML for joomla package to premium and not */
function xml_joomla (str) {
	return str.indexOf(' premium="1"') !== -1 ? '' : str;
}
/* replace current version with the last one, core */
function version_core (str) {
	return n;
}
/* replace current version with the last one, Drupal */
function version_drupal (str) {
	return str.indexOf('version') != -1 ? 'version = ' + n : str;
}
/* replace current version with the last one, Wordpress */
function version_wordpress (str) {
	return str.indexOf('@version') != -1 ? '// @version    ' + n : (str.indexOf('Version:') != -1 ? 'Version: ' + n : str);
}
/* replace current version with the last one, Joomla */
function version_joomla (str) {
	return str.indexOf('<version>') != -1 ? '<version>' + n + '</version>' : str;
}
/* replace current version with the last one, Bitrix */
function version_bitrix (str) {
	return str.indexOf('"VERSION"') != -1 ? '	"VERSION" => "' + n + '",' : str;
}
/* replace include with file's content */
function include_files (str, src) {
	var fso = new ActiveXObject("Scripting.FileSystemObject"),
		includes = str.match(/(include\([^\']*[^\)]+\);)/g),
		include,
		inc,
		i = 0,
		content,
		file;
	while (include = includes[i++]) {
		inc = include.replace(/dirname\(__FILE__\) \. '\//,"'").replace(/\$folder \. /,'..\\..\\view\\').replace(/(include|require|require_once)\(([^\)]+)\);/,"$2").replace(/\//g,"\\").replace(/['"]/g,'');
		if (inc.indexOf('$') == -1) {
			content = '?>';
			file = fso.OpenTextFile(src + inc, 1);
			while (!file.AtEndOfStream) {
				content += file.ReadLine().replace(/(^|;)[\t\s]*#.*$/).replace(/[\t\s]+/g,' ') + ' ';
			}
			content += '<?php';
			str = str.replace(include, content.replace(/\/\*.+?\*\//g, '').replace(/<\?php[\s]*\?>/g,'').replace(/\?><\?php/g,'').replace(/\?>\r?\n?$/,''));
		}
	}
	return str;
}
/* return build filename */
function build_filename (b) {
	switch (b) {
		case 'netcat' :
			return 'webo.site.insight.' + b + '.v' + n + '.tar.gz';
		default:
			return 'webo.site.insight.' + b + '.v' + n + '.zip';
	}
}